#include<iostream>
using namespace std;
#include<string>
class Solution {
public:
    bool oneEditAway(string first, string second) {
        int m = first.size(), n = second.size();
        if (abs(m - n) > 1)
            return false;
        int  now = 0;
        if (m < n)
            first.swap(second);
        if (m != n) {
            int l = 0, r = 0;
            while (l < m && r < n) {
                if (first[l] == second[r]) {
                    ++l;
                    ++r;
                }
                else {
                    ++l;
                    ++now;
                }
                if (now >= 2)
                    return false;
            }
        }
        else {
            for (int i = 0; i < m; ++i) {
                if (first[i] != second[i])
                    ++now;
                if (now >= 2)
                    return false;
            }
        }
        return true;
    }
};